package com.dogkr.server.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dogkr.server.entity.HostServerDate;
import com.dogkr.server.mapper.HostServerDateMapper;
import com.sean.common.service.BaseService;
@Service
public class ServerDateService extends BaseService {
	
	@Autowired
	private HostServerDateMapper hostServerDateMapper;

	public List<HostServerDate> selectByHost(Long hostId, Date beginDate, Date endDate) {
		Map<String, Object> param = this.getParamMap("hostId", hostId);
		param.put("beginDate", beginDate);
		param.put("endDate", endDate);
		return hostServerDateMapper.selectByParam(param);
	}

	public void saveCloseDate(Long hostId, Date date) {
		HostServerDate sevDate = new HostServerDate();
		sevDate.setHostId(hostId);
		sevDate.setCreateDate(new Date());
		sevDate.setDisableBegan(date);
		sevDate.setDisableEnd(date);
		hostServerDateMapper.insert(sevDate);
	}

	public void saveOpenDate(Long hostId, Date date) {
		hostServerDateMapper.deleteByParam(this.getParamMap("hostId", hostId, "date", date));
	}
	
}
